define(function (require, exports, module) {
  var mCard = require('andrew/card/index.js')
  var Element = require('third/element/index.js')
  var UrlHelper = require('tools/urlHelper.js')
  var api = require('service/api.js');

  var app = new Vue({
    mixins: [Element.mixin],
    data() {
      return {
        form: {
          id: 0,
          title: '',
          summary: '',
          categoryId: 0,
          categoryName: '',
          dataFlag: '1'
        },
        DataFlagEnum: [{
          value: 1,
          label: '有效'
        }, {
          value: 0,
          label: '无效'
        }],
        CategoryEnum: []
      }
    },
    mounted: function () {
      var urlParamMap = UrlHelper.getUrlParamsMap()
      var id = urlParamMap['id'] || urlParamMap['Id'] || 0
      if (id > 0) {
        api.getArtSimpleMod(function (res) {
          this.form = res;
        });
      }
      this.getCategoryList()
    },
    methods: {
      getCategoryList: function () {
        this.CategoryEnum = [{
          id: 3,
          name: '业务体系-立方停车'
        }, {
          id: 4,
          name: '业务体系-门禁通道'
        }, {
          id: 7,
          name: '新闻中心-新闻动态'
        }, {
          id: 8,
          name: '新闻中心-市场推广'
        }]
      },
      onSubmit: function () {
        console.log(this.form)
      },
      onCancel: function () {
        $(window).parent.layer.close()
      },

      onCategorySelected(value) {
        var curCategoryNameItem = _.find(pageVue.CategoryEnum, { id: value })
        pageVue.form.categoryName = curCategoryNameItem.name.split('-')[1]
        console.log(pageVue.form.categoryName)
      },

      handleEdit(index, row) {
        console.log(index, row)
      },
      handleArtEdit(index, row) {
        console.log(index, row)
      },

      handleDelete(index, row) {
        console.log(index, row)
      }
    }
  }).$mount('#app')
})
